<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\crm\controller;
use think\Loader;
use think\Cache;

class Hotline extends CrmController
{
    /**
     * 渲染模板customerList
     */
    public function hotlineResources()
    {
        $menuname = "Hotline Resources";
        $p_menuname = $_SESSION['menu'][$menuname]; //父菜单
        $priv = $_SESSION["user_priv"][$p_menuname][$menuname];     
        $this->assign("priv",$priv);

        $result = Loader::model('Department')->recursionDepartment();
        $result = Loader::model('Department')->recursionDepartmentArr($result);
        $this->assign('options', $result);

        $arrUsers = Loader::model('Users')->getUsersList();
        $this->assign("arrUsers",$arrUsers);

        $member = Cache::get('member');
        $this->assign("member",$member);

        // 模板输出
        return $this->fetch('hotlineResources');
    }


    /**
     * 获取客户资料列表
     * @return [json] [客户资料列表]
     */
    public function hotlineResourcesData()
    {
        // $users = Cache::get('users');
        $page = $_REQUEST["page"];
        $limit = $_REQUEST["limit"];
        //需先判断传值是否为空
        // print_r($_REQUEST);exit;
        $where = "(1 ";
        $where .= empty($_REQUEST["id_card"])?"":" AND id_card like '%".$_REQUEST["id_card"]."%'";

        /*$last_order_time = date('Y-m-d', time() - substr($_REQUEST["last_order_time"], 1)*24*3600);
        $where .= empty($_REQUEST["last_order_time"])?"":" AND last_order_time like '%".$last_order_time."%'";*/
        $where .= " )";
        // print_r($where);exit;

        $arrData = Loader::model('Hotline')->hotlineResourcesData($where,$page,$limit);
        echo json_encode($arrData);
    }





}